package com.hb.service.role.impl;
            
import com.hb.pojo.po.role.Role;
import com.hb.pojo.vo.role.RoleVo;
import com.hb.pojo.dto.role.RoleDto;
import com.hb.service.role.RoleService;
import com.hb.mapper.role.RoleMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Resource
    private RoleMapper roleMapper;

    @Override
    public Role selectByPrimaryKey(Integer id) {
        return roleMapper.selectByPrimaryKey(id);
    }

    @Override
    public Role selectByRoleName(String roleName){ return roleMapper.selectByRoleName(roleName);}

    @Override
    public Role insertSelective(RoleVo roleVo) {
        int i = roleMapper.insertSelective(roleVo);
        return i > 0 ? roleMapper.selectByPrimaryKey(roleVo.getRole_id()) : null;
    }

    @Override
    public Role updateByPrimaryKeySelective(RoleVo roleVo) {
        int i = roleMapper.updateByPrimaryKeySelective(roleVo);
        return i > 0 ? roleMapper.selectByPrimaryKey(roleVo.getRole_id()) : null;
    }
    
    @Override
    public Role updateByPrimaryKey(RoleVo roleVo) {
        int i = roleMapper.updateByPrimaryKey(roleVo);
        return i > 0 ? roleMapper.selectByPrimaryKey(roleVo.getRole_id()) : null;
    }

    /**
     * query role list
     */
    @Override
    public List<RoleDto> selectByVo(RoleVo roleVo) {
        return roleMapper.selectByVo(roleVo);
    }
}